<?php
session_start();
if (isset($_POST['op']) || true){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    $openid=addslashes($_POST['op']);
    $limitNum=20;
    $query=$mysqli->query("SELECT topnum FROM z_game where is_open='1' limit 0, 1");
    if($query->num_rows>0){
        $getLimit=$query->fetch_assoc();
        $limitNum=$getLimit['topnum'];
    }
    
    
    $queryP=$mysqli->query("select ishuojiang,openid,fen from ".$tableVer."_fen order by fen desc limit 0, ".$limitNum);
    $userPai=array();
    $userPaiNum=0;
    $i=0;
    while ($list=$queryP->fetch_assoc()){
        $queryU=$mysqli->query("select nickname,headimg from ".$tableVer."_users where openid='".$list['openid']."' limit 0, 1");
        $getU=$queryU->fetch_assoc();
        if (1 == $list['ishuojiang']){
            $ishuojiang=1;
        }else{
            $ishuojiang=0;
        }
        $userPai[]=array('hj'=>$ishuojiang,'f'=>$list['fen'],'n'=>base64_decode($getU['nickname']), 'a'=>$getU['headimg']);
        $i++;
        if ($list['openid'] == $openid){
            $userPaiNum=$i;
        }
    }
    
    $queryT=$mysqli->query("select fen from ".$tableVer."_fen where openid='".$openid."' limit 0, 1");
    $userFen=0;
    if($queryT->num_rows>0){
        $getUInfo=$queryT->fetch_assoc();
        $userFen=$getUInfo['fen'];
    }
    echo json_encode(array('s'=>'y','p'=>$userPai,'up'=>$userPaiNum,'fen'=>$userFen));
    
}
?>
